import { request } from "@/utils/service"
import type * as menu from "./types/menu"
import type * as admin from "./types/admin"
import type * as Role from "./types/Role"

/** 获取动态路由地址 */
export function getPermissionRouter() {
  return request<menu.SystemMenuResponseData>({
    url: "User/getPermissionRouter",
    method: "get"
  })
}
//#region admin

/** 查 */
export function getAdminListApi(params: admin.GetTableRequestData) {
  return request<admin.GetTableResponseData>({
    url: "admin/adminList",
    method: "get",
    params
  })
}
export function getAdminRoleListApi(params: admin.GetListRequestData) {
  return request<admin.GetListResponseData>({
    url: "admin/adminRoleList",
    method: "get",
    params
  })
}

/** 查详情 */
export function getAdminDetailApi(params: admin.GetDetailRequestData) {
  return request<admin.GetDetailResponseData>({
    url: "admin/adminDetail",
    method: "get",
    params
  })
}

export function CreateRequestData(data: admin.CreateRequestData) {
  return request({
    url: "admin/adminAdd",
    method: "post",
    data
  })
}
export function updateAdminEditApi(data: admin.UpdateRequestData) {
  return request<admin.UpdateResponseData>({
    url: "admin/adminEdit",
    method: "put",
    data
  })
}

export function deleteAdminDeleteDataApi(data: admin.DeleteRequestData) {
  return request({
    url: `admin/adminDelete`,
    method: "delete",
    data
  })
}
export function adminEditPasswordApi(data: admin.passwordEditRequestData) {
  return request<admin.passwordEditResponseData>({
    url: "admin/adminEditPassword",
    method: "put",
    data
  })
}

//#endregion
export function getRoleListApi(params: Role.GetListsRequestData) {
  return request<Role.GetListsResponseData>({
    url: "Role/roleList",
    method: "get",
    params
  })
}
export function getRoleDetailApi(params: Role.GetDetailRequestData) {
  return request<Role.GetDetailResponseData>({
    url: "Role/roleDetail",
    method: "get",
    params
  })
}
export function CreateRoleRequestData(data: Role.CreateRequestData) {
  return request({
    url: "Role/roleAdd",
    method: "post",
    data
  })
}
export function UpdateRoleRequestData(data: Role.UpdateRequestData) {
  return request({
    url: "Role/roleEdit",
    method: "put",
    data
  })
}
export function DeleteRoleRequestData(data: Role.DeleteRequestData) {
  return request({
    url: "Role/roleDelete",
    method: "delete",
    data
  })
}

export function getMenuListApi(params: menu.GetListsRequestData) {
  return request<menu.SystemMenuResponseData>({
    url: "Menu/menuList",
    method: "get",
    params
  })
}
export function getMenuDetailApi(params: menu.GetDetailRequestData) {
  return request<any>({
    url: "Menu/menuDetail",
    method: "get",
    params
  })
}
export function CreateMenuRequestData(data: menu.CreateRequestData) {
  return request({
    url: "menu/menuAdd",
    method: "post",
    data
  })
}
export function EditMenuRequestData(data: menu.UpdateRequestData) {
  return request({
    url: "menu/menuEdit",
    method: "put",
    data
  })
}
export function deleteMenuDataApi(data: menu.DeleteRequestData) {
  return request({
    url: `menu/menuDelete`,
    method: "delete",
    data
  })
}
